package 函数式接口.四大函数式接口;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;

public class MyPridict {

    public static void main(String[] args) {

        List<String> list = Arrays.asList("sd", "sdf", "sdfdsgdf");

        method(new Predicate<String>() {
            @Override
            public boolean test(String s) {
                return s.startsWith("sd");
            }
        }, list);


        List<String> sd = method(s -> s.startsWith("sd"), list);
    }


    public static List<String> method(Predicate<String> predicate, List<String> list) {
        List<String> list1 = new ArrayList<>();
        for (String str : list) {
            if (predicate.test(str)) {
                list1.add(str);
            }
        }
        return list1;
    }
}
